package br.ime.usp.mestrado.cosen.jboss.mc.example.tests;

import java.net.URL;

import org.jboss.dependency.spi.ControllerContext;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelController;

import br.ime.usp.mestrado.cosen.jboss.mc.example.beans.Engenheiro;
import br.ime.usp.mestrado.cosen.jboss.mc.util.MCBootstrap;

public class TesteEngenheiroCalculadoraInjecao {
	public static void main(String[] args) {
		MCBootstrap bootstrap = new MCBootstrap();
		bootstrap.run();
		
		ClassLoader cl = Thread.currentThread().getContextClassLoader();
		URL url = cl.getResource("engenheiro-calculadora-injecao-beans.xml");
		bootstrap.deploy(url);
		
		Kernel kernel = bootstrap.getKernel();
		KernelController controller = kernel.getController();
		
		ControllerContext context = controller.getInstalledContext("Engenheiro");
		Engenheiro engenheiro = (Engenheiro) context.getTarget();
		
		engenheiro.trabalha();
	}
}
